import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class 第K个排列 {
    
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        //接收输入 n
        int len = Integer.parseInt(in.nextLine());
        //接收输入 K
        int k = Integer.parseInt(in.nextLine());

        //输入数据列表
        LinkedList<Integer>  inputList = new LinkedList<>();
        int position = 1;

        for(int i=1; i<=len; i++){
            inputList.add(i);
            position = position * i;
        }

        //记录结果
        StringBuilder builder = new StringBuilder();
        k = k-1;

        for(int i=len; i>0; i--){

            position = position / i;
            int num = k / position;
            builder.append(inputList.remove(num));
            k = k%position;
        }

        System.out.println(builder.toString());

    }
}
